from bs4 import BeautifulSoup
from newspaper import Article
import requests

url = 'https://www.globaltimes.cn/page/202510/1345058.shtml'

# 加载网页内容。静态网页用requests，动态网页暂时不考虑
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
}  # 添加User-Agent避免被网站拒绝
# 发送请求并指定编码
response = requests.get(url, headers=headers)
response.encoding = response.apparent_encoding  # 自动识别网页内容编码，避免乱码

# 原始网页内容
# print(response.text)
# print(response.apparent_encoding)
# print("-------------------")

# 解析 HTML - 使用 BeautifulSoup
soup = BeautifulSoup(response.text, 'html.parser')  # "html.parser"是Python内置解析器，无需额外安装

# 输出网站内容
print(soup.text)
print("-------------------")